Ext.namespace("Meeting");

Meeting.Today=function(){
		this.myTime="";
		this.btnAdd = new Ext.Toolbar.Button({
	        iconCls: 'icon-add',
	        text: '新增',
	        tooltip: {text: '新增工作'},
	        scope: this,
	        handler:this.addMeeting
	    });

		this.cm = new Ext.grid.ColumnModel([		
				new Ext.grid.RowNumberer(),
				{header: 'mtId', width: 5, hidden: true, dataIndex: 'MT_ID'},
				{header:'工作名称', width: 120,dataIndex:'MT_NAME',sortable:true},
				{header:'工作开始时间', width: 80,dataIndex:'MT_START_DATE',sortable:true},
				{header:'工作结束时间', width: 80,dataIndex:'MT_END_DATE',sortable:true},
				{header:'工作发起人', width: 120,dataIndex:'USER_NAME',sortable:true}
		]);					
		
		this.store = new Ext.data.JsonStore({
				url:'../meeting/searchMeetingByDate.form?timesnap='+Date.parse(new Date()),
				method:'post',
				root:'result',					
				totalProperty:'total',
				id:'mtId',
				fields:['MT_ID', 'MT_NAME', 'MT_ROOM', 'MT_START_DATE', 'MT_END_DATE', 'MT_CREATOR', 'MT_ASSIGNER', 'MT_JOINER', 'MT_SUMMARY', 'MT_SUMMARY_URL', 'MT_LEVEL', 'MT_ATTENTION', 'MT_NOTICE', 'MT_STATUS','USER_NAME']
		});
		
		this.grid = new Ext.grid.GridPanel({
				width: 550,	
				frame:true,
				title:'工作列表',
				autoHeight: true,				
				store: this.store,	
				cm: this.cm,
				sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
				//renderTo: 'grid',				
				loadMask: {msg: '加载中，请稍候...'}
		});
		//this.on('dblclick',this.editMeeting,this);
		
			
		Meeting.Today.superclass.constructor.call(this, {
	        bodyStyle: 'padding: 5px 5px 0',
	        height: 500,
	        width: 550,
	        resizable: false,
	        frame:true,
	        plain: true,
	        modal: true,
	        autoScroll: true,
	        closeAction: 'hide',
	        items: [this.grid]
	        //buttons: [this.btnAdd]
	});
};
Ext.extend(Meeting.Today, Ext.Window, {
	initData:function(data){
		if(data){
			this.myTime=data.format('Y-m-d');
		}
		this.store.load({params:{mtStartDate:this.myTime?this.myTime:new Date().format('Y-m-d')}});
	},
	addMeeting:function(){
		if(!Meeting.Add.instance)
			Meeting.Add.instance = new Meeting.Add();
			Meeting.Add.instance.show();
			Meeting.Add.instance.initAddData();
		}
});
